//
//  UIButton+Extension.swift
//  weibo
//
//  Created by nick on 15/9/22.
//  Copyright © 2015年 cn.nick. All rights reserved.
//

import UIKit

extension UIButton {
    
    convenience init (imageName: String, bgImageName: String?) {
        self.init()
        
        setImage(UIImage(named: imageName), forState: UIControlState.Normal)
        setImage(UIImage(named: imageName + "_highlighted"), forState: UIControlState.Highlighted)
        if bgImageName != nil {
            
            setBackgroundImage(UIImage(named: bgImageName!), forState: UIControlState.Normal)
            setBackgroundImage(UIImage(named: bgImageName! + "_highlighted"), forState: UIControlState.Highlighted)
        }
        sizeToFit()
        
    }
    
    convenience init (title: String, imageName: String, titleColor: UIColor) {
        self.init()
        
        setTitle(title, forState: UIControlState.Normal)
        setTitleColor(titleColor, forState: UIControlState.Normal)
        setBackgroundImage(UIImage(named: imageName), forState: UIControlState.Normal)
        setTitleColor(titleColor, forState: UIControlState.Normal)
        
    }
    

}
